package com.zxt.dlna.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.zxt.dlna.application.MyStartService;

public class BootReceiver extends BroadcastReceiver {
    private final String TAG = "BootReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "onReceive: "+intent.getAction());
        if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())
        || Intent.ACTION_LOCKED_BOOT_COMPLETED.equals(intent.getAction())
        || Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())
        || Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction())
        || Intent.ACTION_PACKAGE_INSTALL.equals(intent.getAction())) {
            // 在这里添加启动完成后的处理逻辑
            // 例如启动服务或执行其他初始化操作
            // StartActivity 启动
//            Intent startIntent = new Intent(context, StartActivity.class);
//            startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//            context.startActivity(startIntent);
            // 或者启动你自定义的服务
             Intent myServiceIntent = new Intent(context, MyStartService.class);
             context.startService(myServiceIntent);
        }
    }
}
